package com.hoperun.checkcloth.net

import com.google.gson.JsonObject
import com.google.gson.annotations.SerializedName
import com.hoperun.checkcloth.common.GET_NEW_VERSION_APP_NAME
import com.hoperun.checkcloth.util.LanguageUtil

data class LeftOverBoltLoginRequest(
        @SerializedName("YHM") val account: String,
        @SerializedName("YHKL") val password: String,
        @SerializedName("BMMC") val bmmc: String = ""
)

data class LeftOverBoltLoginResponse(
        @SerializedName("OPT_FLAG") val flag: String,
        @SerializedName("MSG_INFO") val message: String?,
        @SerializedName("userBean") val userBean: JsonObject? = null,
        @SerializedName("RYXXID") val ryxxId: String,
        @SerializedName("YHM") val yhm: String,
        @SerializedName("BMJC") val bmjc: String,
        @SerializedName("XM") val name: String
)

data class LeftOverBoltClothNoQueryRequest(
        @SerializedName("CLOTHTKTNO") val clothNo: String,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

data class LeftOverBoltClothFlawInfoCommitRequest(
        val userBean: JsonObject,
        @SerializedName("CLOTHTKTNO") val clothNo: String,
        @SerializedName("XCXX") val flawList: List<ClothFlawInfo>,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

data class LeftOverBoltClothFlawInfoCommitResponse(
        @SerializedName("FLAG") val flag: String,
        @SerializedName("ERRORMESSAGE") val errMessage: String
)

/***
 *  坯布检验系统登录请求参数
 */
data class GrayClothLoginRequest(
        @SerializedName("YHBH") val account: String,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

/***
 *  坯布检验系统，根据三联号查询相关信息请求参数
 */
data class GrayClothQueryRequest(
        @SerializedName("MONADNO") val monadNo: String,
        @SerializedName("YHBH") val account: String,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

/***
 *  坯布检验系统，瑕疵信息提交请求参数
 */
data class GrayClothFlawInfoCommitRequest(
        @SerializedName("MONADNO") val monadNo: String,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr(),
        @SerializedName("BATCHNO") val batchNo: String,
        @SerializedName("CLOTHNO") val clothNo: String,
        @SerializedName("MACHINENO") val machineNo: String,
        @SerializedName("WEIGHT") val weight: String,
        @SerializedName("METERLONG") val meterLong: String,
        @SerializedName("GRADENO") val gradeNo: String,
        @SerializedName("EMPID") val empId: String,
        @SerializedName("CLOTHWORKER") val clothWorker: String,
        @SerializedName("XCXX") val flawList: List<ClothFlawInfo>
)

data class GetNewVersionRequest(
        @SerializedName("appname") val appName: String = GET_NEW_VERSION_APP_NAME,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

data class GetNewVersionResponse(
        @SerializedName("OPT_FLAG") val flag: String,
        @SerializedName("MSG_INFO") val message: String,
        @SerializedName("DATA") val info: UpgradeInfo? = null
)

data class QueryDataDictRequest(
        @SerializedName("SJZDID") val id: String,
        @SerializedName("LANGUAGE") val language: String = LanguageUtil.getLanguageStr()
)

data class QueryDataDictResponse(
        @SerializedName("FLAG") val flag: String,
        @SerializedName("ERRORMESSAGE") val errMessage: String,
        @SerializedName("DATA") val data1: List<DictItem>? = null,
        @SerializedName("DATA2") val data2: List<DictItem>? = null,
        @SerializedName("DATA3") val data3: List<DictItem>? = null,
        @SerializedName("DATA4") val data4: List<DictItem>? = null
)

/***
 * 瑕疵信息
 */
data class ClothFlawInfo(
        @SerializedName("XCID") val id: String,
        @SerializedName("XCMC") val name: String,
        @SerializedName("XCSL") val number: Int
) {
    operator fun unaryPlus(): ClothFlawInfo = copy(number = number + 1)
    operator fun unaryMinus(): ClothFlawInfo = copy(number = number - 1)
    operator fun plus(integer: Int): ClothFlawInfo = copy(number = number + integer)
    infix fun inc(i: Int): ClothFlawInfo = copy(number = number + i)
    infix fun dec(i: Int): ClothFlawInfo = copy(number = number - i)
    infix fun set(i: Int): ClothFlawInfo = copy(number = i)
}


/***
 * 字典数据条目
 */
data class DictItem(
        @SerializedName("KEYCODE") val key: String = "",
        @SerializedName("SJXZ") val value: String = ""
)


